package cs235.java;

public class StudentImpl extends PersonImpl implements Student {

    private String _major;
    private double _gpa;
    private static final double MAXGPA = 4.0;
    private static final double MINGPA = 0.0;

    public String getMajor() {
        return _major;
    }

    public void setMajor(String major) {
        if (major == null) {
            throw new IllegalArgumentException("Major cannot be null");
        }
        _major = major;
    }

    public double getGPA() {
        return _gpa;
    }

    public void setGPA(double gpa) {
        if (gpa > MAXGPA) {
            throw new IllegalArgumentException("GPA cannot be higher than: "
                    + MAXGPA);
        } else if (gpa < MINGPA) {
            throw new IllegalArgumentException("GPA cannot be lower than:"
                    + MINGPA);
        }
        _gpa = gpa;
    }

    public String toString() {
        return "student\n" + getID() + "\n" + getName() + "\n" + getMajor()
                + "\n" + getGPA() + "\n";
    }

}
